/**
 * @author Nicolas Lusa (lusan@usi.ch)
 */

package ch.usi.inf.pf2.gui.action;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;

import ch.usi.inf.pf2.circuit.Component;
import ch.usi.inf.pf2.gui.Model;


public final class SelectAllAction extends AbstractAction {

	private static final long serialVersionUID = -4764074690023642777L;
	private final Model model;
    
    
    public SelectAllAction(final Model model) {
        this.model = model;
        putValue(NAME, "Select all");
        final ImageIcon icon = new ImageIcon(getClass().getResource("../icons/select_all.png"));
        putValue(SMALL_ICON, icon);
        putValue(SHORT_DESCRIPTION, "Select all shapes");
    }
    
    public void actionPerformed(final ActionEvent ev) {
        for (final Component shape : model.getCircuit()) {
            model.getSelection().add(shape);
        }
    }
}
